OpenCores

Programming Model

Programming Model

THEIA's pixels shaders are written using the THEIA programming language.
This is an assembly programming language consisting of a series of instructions
that operate on a series of registers. There is no stack.
The following diagram illustrates THEIA's programming model.

Programming Model Overview


Registers: THEAI has 4 types of registers.
• Internal Registers:
Accessibility: Read-Only.
Scope: The values of these registers can change from one pixel iteration to the next.
Purpose: They are special registers used by the internal GPU routines. Sometimes
you may want to read from these registers. Examples: CREG_CAMERA_POSITION,
CREG_RESOLUTION, CREG_PIXEL_2D_POSITION, etc.

General purpose Registers:
Accessibility: Read-Write.
Scope: The values of these registers can change from one pixel iteration to the
next. This means that even though you can write any value you want, you are not guaranteed that this value will be persistent from one pixel iteration to the next. Purpose: You can basically store whatever you want in these registers, but again, the values are only kept for the duration of your shader.
Constant Registers: Accessibility: Read-Write. Scope: The values of these registers are kept for the entire duration of the GPU
execution. This means that if you store a value, this value is kept until you replace
it with a different value or reset the GPU.
Purpose: Although you can use these registers as you like, the idea is to store
constants during a special execution stage, so that you can reuse these values for
each pixel iteration.

Output Registers: Accessibility: Write-Only.
Scope: The values of these registers can change from one pixel iteration to the
next.
Purpose: These are special registers that indicate an output from a particular stage
of THEIA's execution. Examples: OREG_PIXEL_COLOR, OREG_TEX_COORD1,
OREG_TEXWEIGHT1, etc.

Instructions: THEIA has arithmetic, logic and flow control instructions. There are two flavors of
instructions:
Type 1: OPERATION DESTINATION SOURCE_REGISTER1 SOURCE_REGISTER2
Type 2: OPERATION DESTINATION IMMEDIATE_VALUE

The instructions set and examples are found under the 'Examples' folder on the SVN tree.